home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / rpcsvc / nfs_prot.x < prev    next >
Text File  |  1990-01-29  |  6KB  |  328 lines

  1. /*    @(#)nfs_prot.x    1.2 88/05/08 4.0NFSSRC SMI    */
  2.  
  3. /* 
  4.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  5.  * @(#) from SUN 1.3
  6.  */
  7.  
  8. const NFS_PORT          = 2049;
  9. const NFS_MAXDATA       = 8192;
  10. const NFS_MAXPATHLEN    = 1024;
  11. const NFS_MAXNAMLEN    = 255;
  12. const NFS_FHSIZE    = 32;
  13. const NFS_COOKIESIZE    = 4;
  14. const NFS_FIFO_DEV    = -1;    /* size kludge for named pipes */
  15.  
  16. /*
  17.  * File types
  18.  */
  19. const NFSMODE_FMT  = 0170000;    /* type of file */
  20. const NFSMODE_DIR  = 0040000;    /* directory */
  21. const NFSMODE_CHR  = 0020000;    /* character special */
  22. const NFSMODE_BLK  = 0060000;    /* block special */
  23. const NFSMODE_REG  = 0100000;    /* regular */
  24. const NFSMODE_LNK  = 0120000;    /* symbolic link */
  25. const NFSMODE_SOCK = 0140000;    /* socket */
  26. const NFSMODE_FIFO = 0010000;    /* fifo */
  27.  
  28. /*
  29.  * Error status
  30.  */
  31. enum nfsstat {
  32.     NFS_OK= 0,        /* no error */
  33.     NFSERR_PERM=1,        /* Not owner */
  34.     NFSERR_NOENT=2,        /* No such file or directory */
  35.     NFSERR_IO=5,        /* I/O error */
  36.     NFSERR_NXIO=6,        /* No such device or address */
  37.     NFSERR_ACCES=13,    /* Permission denied */
  38.     NFSERR_EXIST=17,    /* File exists */
  39.     NFSERR_NODEV=19,    /* No such device */
  40.     NFSERR_NOTDIR=20,    /* Not a directory*/
  41.     NFSERR_ISDIR=21,    /* Is a directory */
  42.     NFSERR_FBIG=27,        /* File too large */
  43.     NFSERR_NOSPC=28,    /* No space left on device */
  44.     NFSERR_ROFS=30,        /* Read-only file system */
  45.     NFSERR_NAMETOOLONG=63,    /* File name too long */
  46.     NFSERR_NOTEMPTY=66,    /* Directory not empty */
  47.     NFSERR_DQUOT=69,    /* Disc quota exceeded */
  48.     NFSERR_STALE=70,    /* Stale NFS file handle */
  49.     NFSERR_WFLUSH=99    /* write cache flushed */
  50. };
  51.  
  52. /*
  53.  * File types
  54.  */
  55. enum ftype {
  56.     NFNON = 0,    /* non-file */
  57.     NFREG = 1,    /* regular file */
  58.     NFDIR = 2,    /* directory */
  59.     NFBLK = 3,    /* block special */
  60.     NFCHR = 4,    /* character special */
  61.     NFLNK = 5,    /* symbolic link */
  62.     NFSOCK = 6,    /* unix domain sockets */
  63.     NFBAD = 7,    /* unused */
  64.     NFFIFO = 8     /* named pipe */
  65. };
  66.  
  67. /*
  68.  * File access handle
  69.  */
  70. struct nfs_fh {
  71.     opaque data[NFS_FHSIZE];
  72. };
  73.  
  74. /* 
  75.  * Timeval
  76.  */
  77. struct nfstime {
  78.     unsigned seconds;
  79.     unsigned useconds;
  80. };
  81.  
  82.  
  83. /*
  84.  * File attributes
  85.  */
  86. struct fattr {
  87.     ftype type;        /* file type */
  88.     unsigned mode;        /* protection mode bits */
  89.     unsigned nlink;        /* # hard links */
  90.     unsigned uid;        /* owner user id */
  91.     unsigned gid;        /* owner group id */
  92.     unsigned size;        /* file size in bytes */
  93.     unsigned blocksize;    /* prefered block size */
  94.     unsigned rdev;        /* special device # */
  95.     unsigned blocks;    /* Kb of disk used by file */
  96.     unsigned fsid;        /* device # */
  97.     unsigned fileid;    /* inode # */
  98.     nfstime    atime;        /* time of last access */
  99.     nfstime    mtime;        /* time of last modification */
  100.     nfstime    ctime;        /* time of last change */
  101. };
  102.  
  103. /*
  104.  * File attributes which can be set
  105.  */
  106. struct sattr {
  107.     unsigned mode;    /* protection mode bits */
  108.     unsigned uid;    /* owner user id */
  109.     unsigned gid;    /* owner group id */
  110.     unsigned size;    /* file size in bytes */
  111.     nfstime    atime;    /* time of last access */
  112.     nfstime    mtime;    /* time of last modification */
  113. };
  114.  
  115.  
  116. typedef string filename<NFS_MAXNAMLEN>; 
  117. typedef string nfspath<NFS_MAXPATHLEN>;
  118.  
  119. /*
  120.  * Reply status with file attributes
  121.  */
  122. union attrstat switch (nfsstat status) {
  123. case NFS_OK:
  124.     fattr attributes;
  125. default:
  126.     void;
  127. };
  128.  
  129. struct sattrargs {
  130.     nfs_fh file;
  131.     sattr attributes;
  132. };
  133.  
  134. /*
  135.  * Arguments for directory operations
  136.  */
  137. struct diropargs {
  138.     nfs_fh    dir;    /* directory file handle */
  139.     filename name;        /* name (up to NFS_MAXNAMLEN bytes) */
  140. };
  141.  
  142. struct diropokres {
  143.     nfs_fh file;
  144.     fattr attributes;
  145. };
  146.  
  147. /*
  148.  * Results from directory operation
  149.  */
  150. union diropres switch (nfsstat status) {
  151. case NFS_OK:
  152.     diropokres diropres;
  153. default:
  154.     void;
  155. };
  156.  
  157. union readlinkres switch (nfsstat status) {
  158. case NFS_OK:
  159.     nfspath data;
  160. default:
  161.     void;
  162. };
  163.  
  164. /*
  165.  * Arguments to remote read
  166.  */
  167. struct readargs {
  168.     nfs_fh file;        /* handle for file */
  169.     unsigned offset;    /* byte offset in file */
  170.     unsigned count;        /* immediate read count */
  171.     unsigned totalcount;    /* total read count (from this offset)*/
  172. };
  173.  
  174. /*
  175.  * Status OK portion of remote read reply
  176.  */
  177. struct readokres {
  178.     fattr    attributes;    /* attributes, need for pagin*/
  179.     opaque data<NFS_MAXDATA>;
  180. };
  181.  
  182. union readres switch (nfsstat status) {
  183. case NFS_OK:
  184.     readokres reply;
  185. default:
  186.     void;
  187. };
  188.  
  189. /*
  190.  * Arguments to remote write 
  191.  */
  192. struct writeargs {
  193.     nfs_fh    file;        /* handle for file */
  194.     unsigned beginoffset;    /* beginning byte offset in file */
  195.     unsigned offset;    /* current byte offset in file */
  196.     unsigned totalcount;    /* total write count (to this offset)*/
  197.     opaque data<NFS_MAXDATA>;
  198. };
  199.  
  200. struct createargs {
  201.     diropargs where;
  202.     sattr attributes;
  203. };
  204.  
  205. struct renameargs {
  206.     diropargs from;
  207.     diropargs to;
  208. };
  209.  
  210. struct linkargs {
  211.     nfs_fh from;
  212.     diropargs to;
  213. };
  214.  
  215. struct symlinkargs {
  216.     diropargs from;
  217.     nfspath to;
  218.     sattr attributes;
  219. };
  220.  
  221.  
  222. typedef opaque nfscookie[NFS_COOKIESIZE];
  223.  
  224. /*
  225.  * Arguments to readdir
  226.  */
  227. struct readdirargs {
  228.     nfs_fh dir;        /* directory handle */
  229.     nfscookie cookie;
  230.     unsigned count;        /* number of directory bytes to read */
  231. };
  232.  
  233. struct entry {
  234.     unsigned fileid;
  235.     filename name;
  236.     nfscookie cookie;
  237.     entry *nextentry;
  238. };
  239.  
  240. struct dirlist {
  241.     entry *entries;
  242.     bool eof;
  243. };
  244.  
  245. union readdirres switch (nfsstat status) {
  246. case NFS_OK:
  247.     dirlist reply;
  248. default:
  249.     void;
  250. };
  251.  
  252. struct statfsokres {
  253.     unsigned tsize;    /* preferred transfer size in bytes */
  254.     unsigned bsize;    /* fundamental file system block size */
  255.     unsigned blocks;    /* total blocks in file system */
  256.     unsigned bfree;    /* free blocks in fs */
  257.     unsigned bavail;    /* free blocks avail to non-superuser */
  258. };
  259.  
  260. union statfsres switch (nfsstat status) {
  261. case NFS_OK:
  262.     statfsokres reply;
  263. default:
  264.     void;
  265. };
  266.  
  267. /*
  268.  * Remote file service routines
  269.  */
  270. program NFS_PROGRAM {
  271.     version NFS_VERSION {
  272.         void 
  273.         NFSPROC_NULL(void) = 0;
  274.  
  275.         attrstat 
  276.         NFSPROC_GETATTR(nfs_fh) =    1;
  277.  
  278.         attrstat 
  279.         NFSPROC_SETATTR(sattrargs) = 2;
  280.  
  281.         void 
  282.         NFSPROC_ROOT(void) = 3;
  283.  
  284.         diropres 
  285.         NFSPROC_LOOKUP(diropargs) = 4;
  286.  
  287.         readlinkres 
  288.         NFSPROC_READLINK(nfs_fh) = 5;
  289.  
  290.         readres 
  291.         NFSPROC_READ(readargs) = 6;
  292.  
  293.         void 
  294.         NFSPROC_WRITECACHE(void) = 7;
  295.  
  296.         attrstat
  297.         NFSPROC_WRITE(writeargs) = 8;
  298.  
  299.         diropres
  300.         NFSPROC_CREATE(createargs) = 9;
  301.  
  302.         nfsstat
  303.         NFSPROC_REMOVE(diropargs) = 10;
  304.  
  305.         nfsstat
  306.         NFSPROC_RENAME(renameargs) = 11;
  307.  
  308.         nfsstat
  309.         NFSPROC_LINK(linkargs) = 12;
  310.  
  311.         nfsstat
  312.         NFSPROC_SYMLINK(symlinkargs) = 13;
  313.  
  314.         diropres
  315.         NFSPROC_MKDIR(createargs) = 14;
  316.  
  317.         nfsstat
  318.         NFSPROC_RMDIR(diropargs) = 15;
  319.  
  320.         readdirres
  321.         NFSPROC_READDIR(readdirargs) = 16;
  322.  
  323.         statfsres
  324.         NFSPROC_STATFS(nfs_fh) = 17;
  325.     } = 2;
  326. } = 100003;
  327.  
  328.